#!/usr/bin/perl

use Data::Dumper;
use Regexp::Grammars;

my $nocontext = qr{
  <nocontext:>

  <list>

  <rule: list>
    <[expr]>+ % <[sep=([\w,;])]>
    <minimize:>

  <rule: expr>
    <[item]>+ % <[op=([+-])]>
    <minimize:>

  <token:item> (\d+)

}xms;

if ("1+2,3" =~ $nocontext) {
    print Dumper(\%/);
} else {
    die "not matched\n";
}

if ("1" =~ $nocontext) {
    print Dumper(\%/);
} else {
    die "not matched\n";
}

